import { configureStore, combineReducers } from "@reduxjs/toolkit";

// 引入 拆分出去的 reducer
import counter from "./modules/counter";

// 组合 reducers
const rootReducer = combineReducers({
  counter,
});

const store = configureStore({
  reducer: rootReducer,
});

export default store;

// 从 store 本身推断出 `RootState` 和 `AppDispatch` 类型
export type RootState = ReturnType<typeof store.getState>;
// 推断出类型: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = typeof store.dispatch;
